import 'dart:ffi';

import 'package:flutter/src/services/message_codec.dart';
import 'package:flutter_test/flutter_test.dart';
import 'package:rtk_ota_plugin/rtk_ota_plugin.dart';
import 'package:rtk_ota_plugin/rtk_ota_plugin_platform_interface.dart';
import 'package:rtk_ota_plugin/rtk_ota_plugin_method_channel.dart';
import 'package:plugin_platform_interface/plugin_platform_interface.dart';

class MockRtkOtaPluginPlatform
    with MockPlatformInterfaceMixin
    implements RtkOtaPluginPlatform {

  @override
  Future<String?> getPlatformVersion() => Future.value('42');

  @override
  Future<String> connectRemoteDevice(String address) {
    // TODO: implement connectRemoteDevice
    throw UnimplementedError();
  }

  @override
  void disMessage() {
    // TODO: implement disMessage
  }

  @override
  Future<String> getColorPath() {
    // TODO: implement getColorPath
    throw UnimplementedError();
  }

  @override
  Future<String> getFirmwarePath() {
    // TODO: implement getFirmwarePath
    throw UnimplementedError();
  }

  @override
  void initDfuAdapter(String address, String path) {
    // TODO: implement initDfuAdapter
  }

  @override
  void initIosDfuAdapter(String name, String path) {
    // TODO: implement initIosDfuAdapter
  }

  @override
  Future<String> md5(String path) {
    // TODO: implement md5
    throw UnimplementedError();
  }

  @override
  void otaListener(Future Function(MethodCall call)? handler) {
    // TODO: implement otaListener
  }

  @override
  void otaListenerMessage(RtkOtaPluginCallBack callBack) {
    // TODO: implement otaListenerMessage
  }

  @override
  Future<Void> setAddress(String address) {
    // TODO: implement setAddress
    throw UnimplementedError();
  }

  @override
  void setFilePath(String path) {
    // TODO: implement setFilePath
  }
}

void main() {
  final RtkOtaPluginPlatform initialPlatform = RtkOtaPluginPlatform.instance;

  test('$MethodChannelRtkOtaPlugin is the default instance', () {
    expect(initialPlatform, isInstanceOf<MethodChannelRtkOtaPlugin>());
  });

  test('getPlatformVersion', () async {
    RtkOtaPlugin rtkOtaPlugin = RtkOtaPlugin();
    MockRtkOtaPluginPlatform fakePlatform = MockRtkOtaPluginPlatform();
    RtkOtaPluginPlatform.instance = fakePlatform;

    expect(await rtkOtaPlugin.getPlatformVersion(), '42');
  });
}
